/**
	The Minerva Project, DAG Scheduling Tools
	Copyright (C) 2006 Florin Pop & Stefan Bucur

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 */
package ro.pub.cs.minerva.graph;

/**
 * @author Stefan Bucur
 *
 */
public class GraphLink<N extends GraphNode> implements Cloneable {
	Graph graph;
	N startNode;
	N endNode;
	
	
    /*
     * PUBLIC METHODS
     */
	
	public GraphLink(N startNode, N endNode) {
		this.startNode = startNode;
		this.endNode = endNode;
	}
	
	

	public Object clone() throws CloneNotSupportedException {
		GraphLink<? extends GraphNode> result = (GraphLink<? extends GraphNode>)(super.clone());
		
		result.graph = null;
		
		return result;
	}



	public Graph getGraph() {
		return graph;
	}
	
	public N getStartNode() {
		return startNode;
	}
	
	public N getEndNode() {
		return endNode;
	}
	
	public String toString() {
		return "( " + startNode.toString() + " -> " + endNode.toString() + " )";
	}



	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof GraphLink)) {
			return false;
		}
		
		GraphLink link = (GraphLink)obj;
		
		if (this.startNode.equals(link.startNode) && this.endNode.equals(link.endNode))
			return true;
		else
			return false;
	}
	
	
}
